package com.cat.bitOperation;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/split-array-into-maximum-number-of-subarrays/
 * @create 2025/8/22 14:46
 * @since JDK17
 */

public class Solution13 {
    public int maxSubarrays(int[] nums) {
        int and = nums[0], ans = 0, n = nums.length;
        for (int i = 1; i < n; i++) {
            if (and == 0) {
                and = nums[i];
                ans++;
            }
            and &= nums[i];
        }
        return and == 0 ? ans : ans - 1;
    }
}
